﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ScheduleMaker.DB.CoreDAO;
using ScheduleMaker.ConfigManager;
using ScheduleMaker.DB;
using ScheduleMaker.DB.Domain.Core;
using ScheduleMaker.DB.Domain;

namespace ScheduleMaker
{
    public partial class smAdmRoomAddForm : Form
    {
        smAdminForm parentForm;
        //public smAdmRoomAddForm()
        //{
        //    InitializeComponent();
        //}
        public smAdmRoomAddForm( smAdminForm _parentForm )
        {
            InitializeComponent();
            this.parentForm = _parentForm;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (regexpHelper.Instance.isClassroomNameCorrect(tbroomname.Text))
            {

                // Dodawanie nowej sali
                ClassroomDAO classroomDAO = DAOFactory.getClassroomDAO(ConfigManager.ConfigManager.getConfiguration().Type);


                if (ConfigManager.ConfigManager.getConfiguration().Type == Mode.School)
                {
                    DB.Domain.Core.Classroom room = new ClassroomSchool();

                    room.Name = tbroomname.Text;
                    room.Description = tbroomdesc.Text;
                    classroomDAO.save(room);
                }
                else
                {
                    DB.Domain.Core.Classroom room = new ClassroomUniversity();

                    room.Name = tbroomname.Text;
                    room.Description = tbroomdesc.Text;
                    classroomDAO.save(room);
                }

                MessageBox.Show("Sala zsotała dodana", "Dodanie sali", MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.parentForm.getClassroomList();

                this.Dispose();
            }
            else
            {
                MessageBox.Show("Niepoprawna nazwa sali!", "Dodanie sali", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}
